1. Field of the Present Invention
The present invention generally relates to computer graphics and more particularly to a circuit that calculates sphere mode texture coordinates as part of a geometry processing device in a graphics adapter.
2. History of Related Art
Graphics display subsystems are almost universally encountered in microprocessor based computer systems to facilitate a variety of graphics tasks and applications including computer-assisted drafting, architectural design, simulation trainers for aircraft and other vehicles, molecular modeling, virtual reality applications, and video games. Graphics processors, graphics adapters, and a variety of similarly designed computer products provide specialized hardware to speed the execution of graphics instructions and rendering of graphic images. These processors and adapters typically include, for example, circuitry optimized for translating, rotating, and scaling 3D graphic images. In a typical application, a graphical image that is displayed on a display terminal or other output device is composed of one or more graphic primitives. For purposes of this disclosure, a graphic primitive may be thought of as one or more points, lines, or polygons that are associated with one another, such as by being connected to one another. Typically, the displayed image is generated by creating one or more graphic primitives, assigning various attributes to the graphic primitives, defining a viewing point and a viewing volume, determining which of the graphic primitives are within the defined viewing volume, and rendering those graphic primitives as they would appear from the viewing point. This process can require a tremendous amount of computing power to keep pace with the ever increasingly complex graphics applications that are commercially available. Accordingly, designers of graphics systems and graphics applications are continuously seeking cost effective means for improving the efficiency at which graphic images are rendered and displayed.
Typically a software application program generates a 3D graphics scene, and provides the scene, along with lighting attributes, to an application programming interface (API) such as the OpenGL(copyright) API developed by Silicon Graphics, Inc. Complete documentation of OpenGL(copyright) is available in M. Woo et al., OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 1.2 (Addison Wesley Longman, Inc. 1999) and D. Schreiner, OpenGL Reference Manual, Third Edition: The Official Reference Document to OpenGL, Version 1.2 (Addison Wesley Longman, Inc. 1999), both of which are incorporated by reference herein.
A 3D graphics scene typically includes a number of polygons that are delimited by sets of vertices. The vertices are combined to form larger primitives, such as triangles or other polygons. The triangles (or polygons) are combined to form surfaces, and the surfaces are combined to form objects. Each vertex is associated with a set of attributes. Vertex attributes may include a position, including three Cartesian coordinates x, y, and z, a material color, which describes the color of the object to which the vertex belongs, and a normal vector, which describes the direction to which the surface is facing at the vertex. Each vertex may also be associated with texture coordinates and/or an alpha (transparency) value. In addition, the scene itself may be associated with a set of attributes including, as examples, an ambient color that typically describes the amount of ambient light and one or more individual light sources. Each light source has a number of properties associated with it, including a direction, an ambient color, a diffuse color, and a specular color.
Rendering is employed within the graphics system to create two-dimensional image projections of a 3D graphics scene for display on a monitor or other display device. Typically, rendering includes processing geometric primitives (e.g., points, lines, and polygons) by performing one or more of the following operations as needed: transformation, clipping, culling, lighting, fog calculation, and texture coordinate generation. Rendering further includes processing the primitives to determine component pixel values for the display device, a process often referred to specifically as rasterization.
The OpenGL(copyright) API and other API""s such as the DirectX(copyright) API from Microsoft define the allowed vertex and scene attributes and the equations used to determine attribute values. In a conventional graphics adapter, the calculations specified by a particular API are implemented in software. It will be appreciated that software calculations can adversely affect the performance of the graphics adapter, especially if the equations require complex, floating point calculations. It would therefore be desirable to implement, to the extent feasible, some or all of the calculations specified by a particular graphics API in dedicated hardware circuitry. Moreover, it would be desirable if the implemented solution balanced improved performance against cost by optimizing the hardware design to account for such factors as, the frequency with which the particular function or equation is invoked and the speed required of the particular equation.
Among the various calculations specified by the API, it is fairly common to require the inverse square root of a floating point number. It would be desirable to implement the calculation of a floating point""s inverse square root in a dedicated hardware circuit that utilizes sufficient resources to perform the calculations in significantly less time than required to perform the same calculation in software while not unnecessarily increasing the cost or size of the graphics adapter.
The goal identified above is achieved with a floating point inverse square root circuit according to the present invention. The circuit is configured to receive a floating point value comprised of a sign bit, an exponent field, and a mantissa field. The inverse square root circuit includes a lookup table configured to receive at least a portion of the floating point value and further configured to generate an initial approximation (x0) of the inverse square root of the floating point value from the received portion of the floating point value. The inverse square root circuit further includes a first estimation circuit that receives the initial approximation from the lookup table and at least a portion of a value L derived from the floating point value mantissa field (M) and further configured to produce a first approximation (x1) of the floating point value""s inverse square root based upon L and x0 where x1 is a more accurate estimate of the inverse square root than x0. The first estimation circuit may include first, second, and third fixed point multiplication units and first and second fixed point adders where the first multiplication unit is configured to square the initial approximation x0, the first fixed point adder is configured to receive as its inputs the initial approximation x0 and the output of a first shift register that receives the initial approximation x0 as its input, and the second multiplication unit is configured to multiply the output of the first multiplication unit by the initial approximation x0. The third multiplication unit may be configured to multiply the output of the second multiplication unit by L and the second adder may be configured to add the output of the first adder with a shifted and 2""s complemented version of the output of the third multiplier to produce the first approximation x1. The value L may comprise the normalized mantissa field if the exponent of the floating point value is even and two times the normalized mantissa field if the exponent of the floating point value is odd.